package com.shixulin.service.impl;

import com.shixulin.domain.ResponseResult;
import com.shixulin.entity.MyExam;
import com.shixulin.entity.UserExam;
import com.shixulin.mapper.MyExamMapper;
import com.shixulin.mapper.UserExamMapper;
import com.shixulin.service.MyExamService;
import com.shixulin.service.UserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MyExamServiceImpl implements MyExamService {
    @Autowired
    private MyExamMapper myExamMapper;

    @Autowired
    private UserExamMapper userExamMapper;

    @Override
    public ResponseResult getMyExam(int subjectId) {

        //先查询出来paperIds
        List<Integer> subjectIds = userExamMapper.getPaperId(subjectId);

        List<MyExam> userExams = myExamMapper.getMyExam(subjectIds);
        if(userExams!=null&&!userExams.isEmpty()){
            return new ResponseResult(300,"成功",userExams);
        }else{
            return new ResponseResult(505,"失败");
        }
    }
}
